package part13;

/**
 * @author wcj
 * @Date 2021/5/24 16:24
 * @Version 1.0
 */
public class Part137 {
    public static void main(String[] args) {
        try {
            throw new DatabaseException(3, 7, "write fail");
        } catch (DatabaseException e) {
            System.out.println(e);
        }
    }
}

/**
 * String.format()内部创建了Formatter对象调用format方法，但是更加的形象且返回一个字符串
 */
class DatabaseException extends Exception {
    public DatabaseException(int transId, int queryId, String msg) {
        super(String.format("(t%d,q%d) %s", transId, queryId, msg));
    }
}
